import QtQuick
import QtQuick.Controls

Rectangle {
    width: 400
    height: 400

    AnimatedImage {
        id: img
        source: "qrc:/images/rotation.gif"
        x: 150
        y: 150
        width: 150
        height: 148

        // 预定义动画
        NumberAnimation {
            id: predefAnim
            target: img
            properties: "rotation"
            to: 360
            duration: 500

            onStopped: {
                to = to===360 ? 0 : 360
            }
        }
    }

    Button {
        text: "启动预定义动画"
        anchors.bottom: parent.bottom
        onClicked: {
            if (predefAnim.running) return;
            predefAnim.start();
        }
    }
}
